package 力扣;

/**
 * @author yyq
 * @create 2022-06-07 10:34
 */
public class leetcode55 {
    public boolean canJump(int[] nums) {
        int maxLength = -1;
        for (int i = 0;i<nums.length;i++){
            if(maxLength>=i){
                int temp = i + nums[i];
                if(temp>maxLength) maxLength=temp;
                if(maxLength>=nums.length) return true;
                if(nums[maxLength]>=nums.length) return true;
            }
        }
        return false;
    }
}
